package com.googlecode.particlesys.templates;

import java.awt.Color;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.Random;

import javax.imageio.ImageIO;

import com.googlecode.particlesys.objects.AbstractEmitter;
import com.googlecode.particlesys.objects.EParticleShape;
import com.googlecode.particlesys.objects.Particle;

public class MarioMoshpit extends AbstractEmitter {
	
	private static final Random RANDOM = new Random();
	private Image image;

	public MarioMoshpit(int x, int y){
		super(3, 3, x, y, 10, 0);
		
		try {
			this.image = ImageIO.read(new File("media"+File.separator+"mario.png"));
		} catch(IOException e){
			System.out.println("Can't do it!");
			this.image = null;
		}
	}

	@Override
	public Particle getNextParticle(){
		Particle p = new Particle(Color.WHITE, EParticleShape.IMAGE, 48, 48);
		p.setX(x);
		p.setY(y);
		p.setImage(image);
		p.setSpeed(5);
		p.setAngle(RANDOM.nextInt(360));
		p.setLife(75);
		return p;
	}
}